import request from '@/utils/request'

// 查询商机列表
export function listOpportunity(query) {
  return request({
    url: '/opportunity/list',
    method: 'get',
    params: query
  })
}

// 查询商机详细
export function getOpportunity(id) {
  return request({
    url: '/opportunity/' + id,
    method: 'get'
  })
}
// 查询商机详细
export function getOpportunityInfo(id) {
  return request({
    url: '/opportunity/getDetails/' + id,
    method: 'get'
  })
}
// 公共商家分配接口
export function publicAllocation(query) {
  return request({
    url: '/opportunity/publicAllocation/',
    method: 'put',
    params: query
  })
}

// 新增商机
export function addOpportunity(data) {
  return request({
    url: '/opportunity',
    method: 'post',
    data: data
  })
}

// 修改商机
export function updateOpportunity(data) {
  return request({
    url: '/opportunity',
    method: 'put',
    data: data
  })
}

// 删除商机
export function delOpportunity(id) {
  return request({
    url: '/opportunity/' + id,
    method: 'delete'
  })
}
//获取作物列表
export function getCropVarietyList() {
  return request({
    url: '/crop_variety/listData',
    method: 'get'
  })
}
export function deptTreeSelect() {
  //当前登录人本级/下级部门
  let id = localStorage.getItem('user') ? JSON.parse(localStorage.getItem('user')).deptId : ''
  return request({
    url: '/system/user/deptTree?ancestors='+id,
    method: 'get'
  })
}
export function getDeptListData(query) {
  return request({
    url: '/system/dept/list',
    method: 'get',
    params: query
  })
}
//获取所有部门
export function getDeptAllListData(query) {
  return request({
    url: '/system/dept/listAll',
    method: 'get',
    params: query
  })
}
export function getDivisions(query,type) {
  return request({
    url: '/divisions/list/'+type,
    method: 'get',
    params: query
  })
}


